package com.jyw.business.de.domain.dto.web;

import com.jyw.business.de.domain.DeDemandAllocation;
import com.jyw.common.utils.DateUtils;
import com.jyw.common.utils.SecurityUtils;
import com.jyw.common.utils.bean.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
@ApiModel("转交请求实体")
public class TransferDto {

    @ApiModelProperty("需求id")
    @NotNull(message = "需求id不能为空")
    private Long id;

    @ApiModelProperty("被转交人")
    @NotNull(message = "被转交人不能为空")
    private Long user;

    @ApiModelProperty("转交原因")
    @NotEmpty(message = "转交原因不能为空")
    private String reason;

    public DeDemandAllocation buildAllocation() {
        DeDemandAllocation allocation = new DeDemandAllocation();
        allocation.setDemandId(getId());
        allocation.setAllocationUser(getUser());
        allocation.setCreateUser(SecurityUtils.getUserId());
        allocation.setCreateTime(DateUtils.getNowDate());
        return allocation;
    }
}
